import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:sessionStorage.getItem('user') ? JSON.parse(sessionStorage.getItem('user')) : '',
    branchId:'',
    deptId:'',
    empId:'',
    typeId:'',
    roomId:'',
  },
  getters: {
  },
  mutations: {
    //登录成功后，把用户信息存入user
    setUser(state,payload){
      state.user=payload
      sessionStorage.setItem('user',JSON.stringify(payload))
    },
    // 修改分店信息，把branchId存入state
    setBranchId(state,payload){
      state.branchId=payload
    },
     // 修改部门信息，把deptId存入state
     setDeptId(state,payload){
      state.deptId=payload
    },
    // 修改员工信息，把empId存入state
    setEmpId(state,payload){
      state.empId=payload
    },
    // 修改房间种类信息，把typeId存入state
    setTypeId(state,payload){
      state.typeId=payload
    },
    // 修改上海房间信息，把roomId存入state
    setRoomId(state,payload){
      state.roomId=payload
    },
  },
  actions: {
  },
  modules: {
  }
})
